﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Boomlagoon.JSON;

public class EntityStaticParser {
	public static void parseEntityStatic (JSONObject entityStaticJsonObj , EntityStatic entityStatic)
	{
		entityStatic.visibilityEffect = (float)entityStaticJsonObj.GetNumber("visibilityEffect");
		entityStatic.visibilitySuppression = (float)entityStaticJsonObj.GetNumber("visibilitySuppression");
		entityStatic.hpMax = (int)entityStaticJsonObj.GetNumber("hpMax");
		entityStatic.spaceMax = (int)entityStaticJsonObj.GetNumber("spaceMax");
		
		JSONObject quantifiableMaxesJsonObj = entityStaticJsonObj.GetObject("quantifiableMaxes");
		if (quantifiableMaxesJsonObj != null)
		{
			Dictionary<Quantifiable,int> quantifiableMaxes = new Dictionary<Quantifiable,int>();
			entityStatic.quantifiableMaxes = quantifiableMaxes;
			foreach (KeyValuePair<string,JSONValue> pair in quantifiableMaxesJsonObj)
			{
				Quantifiable quantifiable = (Quantifiable)System.Enum.Parse(typeof(Quantifiable) , pair.Key);
				quantifiableMaxes.Add(quantifiable , (int)pair.Value.Number);
			}
		}

		entityStatic.repairRate = (float)entityStaticJsonObj.GetNumber("repairRate");
	}
}
